/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.excesys.exsecs.config;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.stereotype.Component;

/**
 * @author XuYangbo
 */
@Component
public class MqttSubscriber implements DisposableBean, Runnable {

	private Thread thread;

	private volatile boolean stopFlag;

	MqttSubscriber() {
		this.thread = new Thread(this);
		this.thread.start();
	}

	@Override
	public void run() {
		System.out.println("启动守护线程...");
		while (!stopFlag) {
			try {
				Thread.sleep(10000);
			}
			catch (InterruptedException e) {
				e.printStackTrace();
			}

			System.out.println("xxxxxxx");
		}
	}

	@Override
	public void destroy() throws Exception {
		System.out.println("退出守护线程...");
		stopFlag = true;
	}

}
